home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / Tools Plus 2.5.1 ƒ / Tools Plus 2.5.1 / User Manual / 14-System Polling (4 of 4) < prev    next >
Encoding:
Text File  |  1994-05-24  |  21.2 KB  |  477 lines  |  [TEXT/ttxt]

  1. Programming Considerations
  2. ``````````````````````````
  3. • If at some point your application is only concerned with a mouse down
  4.   in a certain area, or a single-click only, or a double-click only, you
  5.   can disrupt the click as soon as you have obtained enough information
  6.   by using ResetMouseClicks.  For example, if your application only
  7.   cares about a single-click and it gets a “double-click, mouse still
  8.   down” mouse event code, ResetMouseClicks will tell PollSystem “forget
  9.   the rest of this click.”
  10.  
  11. • A triple-click should be scrutinized by your application because the
  12.   time between the third mouse-down and the third mouse-up may be longer
  13.   than the allowable limit for consecutive clicks.  This will also
  14.   happen when the user double-clicks, then presses down the mouse button
  15.   the third time and drags.  Use the GetDblTime function to determine
  16.   the maximum number of clock ticks which can occur between mouse-down
  17.   and up events to constitute a consecutive click.
  18.  
  19. • Your application can place cursor zones on a window, then use
  20.   FindCursorZone to determine if a click occurred in one of those zones.
  21.   This can make parts of your window, such as pictures or icons, click-
  22.   sensitive.  See “Cursors” for information about Cursor Tables and
  23.   Cursor Zones.
  24.  
  25. • This event will never occur when the watch cursor is displayed, since
  26.   only buttons can be (optionally) clicked.
  27.  
  28. • Poll.Event is populated with the mouse-down event (as obtained from
  29.   the toolbox Event Manager) that is responsible for the doClick event.
  30.   Some applications need this event to drive custom controls.
  31.  
  32. • A doClick event is not generated when the user clicks in a desk
  33.   accessory’s editing fields.  The process is handled automatically.
  34.  
  35. Valid Polling Record Fields
  36. ```````````````````````````
  37. Poll.Window
  38. Poll.Mouse.What
  39. Poll.Mouse.Down[1].Where
  40. Poll.Mouse.Down[1].When
  41. Poll.Mouse.Down[1].Modifiers
  42. Poll.Event                     (for first mouse-down event only)
  43.  
  44. The next three fields are valid only if the mouse event code is inClick1, inClick2Drag, inClick2, inClick3Drag, or inClick3.
  45.  
  46. Poll.Mouse.Up[1].Where
  47. Poll.Mouse.Up[1].When
  48. Poll.Mouse.Up[1].Modifiers
  49.  
  50. The next three fields are valid only if the mouse event code is inClick2Drag, inClick2, inClick3Drag, or inClick3.
  51.  
  52. Poll.Mouse.Down[2].Where
  53. Poll.Mouse.Down[2].When
  54. Poll.Mouse.Down[2].Modifiers
  55.  
  56. The next three fields are valid only if the mouse event code is inClick2, inClick3Drag, or inClick3.
  57.  
  58. Poll.Mouse.Up[2].Where
  59. Poll.Mouse.Up[2].When
  60. Poll.Mouse.Up[2].Modifiers
  61.  
  62. The next three fields are valid only if the mouse event code is inClick3Drag, or inClick3.
  63.  
  64. Poll.Mouse.Down[3].Where
  65. Poll.Mouse.Down[3].When
  66. Poll.Mouse.Down[3].Modifiers
  67.  
  68. The next three fields are valid only if the mouse event code is inClick3.
  69.  
  70. Poll.Mouse.Up[3].Where
  71. Poll.Mouse.Up[3].When
  72. Poll.Mouse.Up[3].Modifiers
  73.  
  74. Poll.Mouse.Where
  75.  
  76.  
  77.   CONST                   {Mouse Event Codes                      }
  78.     inClick1    = 1;      {single-click completed                 }
  79.     inClick2    = 2;      {double-click completed                 }
  80.     inClick3    = 3;      {triple-click completed                 }
  81.     inClick1Drag=-1;      {single-click, mouse still down         }
  82.     inClick2Drag=-2;      {double-click, mouse still down         }
  83.     inClick3Drag=-3;      {tripple-click, mouse still down        }
  84.  
  85.  
  86.  
  87. Note: For C programmers…  The polling record’s arrays are documented is
  88.       using Pascal nomenclature (the elements are numbered 1, 2 and 3).
  89.       In C, the same array’s elements are numbered 0, 1 and 2 (they
  90.       start at zero).  When C programmers read:
  91.           Poll.Mouse.Down[1].Where
  92.       it indicates the first element of the array, which translates to
  93.       the following C source code:
  94.           Poll.Mouse.Down[0].Where
  95.  
  96. ------------------------------------------------------------------------
  97.  
  98. doPopUpMenu (event)
  99. ```````````````````
  100. Indicator that the user selected a pop-up menu item.
  101.  
  102. Programming Considerations
  103. ``````````````````````````
  104. • If your application determines that the item selected by the user
  105.   should be checked, use CheckPopUp or PopUpMark to mark the item with a
  106.   check mark or other special character.  By default, the previously
  107.   selected item is automatically unchecked (although you can override
  108.   this behavior when creating the pop-up menu).
  109.  
  110. • If your application determines that the selected pop-up menu item
  111.   affects the active editing field, you may want to validate the field’s
  112.   edited text before allowing the user to complete the action.  If this
  113.   is the case, use GetFieldString to obtain a copy of the edited text,
  114.   then your application can check the string for errors.  If an error is
  115.   detected, display an appropriate alert box.  If no error is detected,
  116.   call the SaveFieldString procedure to save the edited text as the
  117.   field’s string, then complete the menu’s action.
  118.  
  119. • A doPopUpMenu event is not generated when the user selects desk
  120.   accessory menus.  These selections are handled automatically.
  121.  
  122. Valid Polling Record Fields
  123. ```````````````````````````
  124. Poll.Window
  125. Poll.Menu.Num
  126. Poll.Menu.Item
  127. Poll.Modifiers
  128.  
  129. ------------------------------------------------------------------------
  130.  
  131. doPictButton (event)
  132. ````````````````````
  133. Indicator that user has clicked a picture button, or is holding down a repeating picture button.
  134.  
  135. The doPictButton event reports that the user has clicked a picture button in the active window.  The doPictButton event is also reported if the user holds down a repeating picture button.  Repeating picture button’s will produce events as long as: [1] the mouse button is held down, [2] the button does not reach the end of its range, and [3] the mouse pointer stays inside the picture button’s region.
  136.  
  137. Programming Considerations
  138. ``````````````````````````
  139. • If the “automatic value change” option is not on, your application has
  140.   to set the picture button’s value by using SetPictButtonVal or
  141.   SetPictButtonValSelect.
  142.  
  143. • If you have created a picture button that is “lock selected” with the
  144.   “automatic value change” option off, and you’ve done this to validate
  145.   the picture button before proceeding to the next stage, do the
  146.   following: validate the button.  If it can proceed to the next stage,
  147.   use SetPictButtonValSelect to deselect the button and increment its
  148.   value, otherwise use SetPictButtonValSelect to deselect the button and
  149.   leave its value unchanged.
  150.  
  151. • If the user clicked a picture button that is functioning like a radio
  152.   button, use SelectPictButton to deselect the other picture buttons in
  153.   the group.
  154.  
  155. • This event will never occur when the watch cursor is displayed, since
  156.   picture buttons cannot be clicked.  The exception is if the
  157.   WatchCursorButtons procedure has been used to allow the watch cursor
  158.   to click picture buttons.
  159.  
  160. • Picture buttons with the “repeating events” option turned on may
  161.   produce doNothing events if your application calls PollSystem more
  162.   frequently than the button changes its value.  This will cause no ill
  163.   side-effects, but you should be aware of this.
  164.  
  165. • A doPictButton event is not generated when the user clicks picture
  166.   buttons in another application, control panel or desk accessory.
  167.   These events are handled automatically.
  168.  
  169. • A negative button number value indicates that the decrementing half of
  170.   a split button was clicked (i.e., “-5” indicates that button 5 is a
  171.   split button, and its value is being decreased).
  172.  
  173. Valid Polling Record Fields
  174. ```````````````````````````
  175. Poll.Window
  176. Poll.Button.Num
  177. Poll.Modifiers
  178.  
  179. ------------------------------------------------------------------------
  180.  
  181. doClickControl (event)
  182. ``````````````````````
  183. Indicator that user clicked a custom control.
  184.  
  185.   The doClickControl event reports that the user has clicked in a custom control.  This event must be handled entirely by your application, since only you know how your custom control should behave.
  186.  
  187. Programming Considerations
  188. ``````````````````````````
  189. • This event will never occur when the watch cursor is displayed, since
  190.   custom controls cannot be clicked.
  191.  
  192. Valid Polling Record Fields
  193. ```````````````````````````
  194. Poll.Window
  195. Poll.Event
  196. Poll.Modifiers
  197.  
  198. ------------------------------------------------------------------------
  199.  
  200. doManual (event)
  201. ````````````````
  202. Indicator that an event has been reported that can’t be processed by Tools Plus.
  203.  
  204.   The doManualEvent event reports that some type of event has occurred which should be processed by your application.  This includes seven (7) possible types of events as defined by the Toolbox Event Manager, which are listed below.  If your application does not make use of any of these events, it can ignore the doManualEvent event code.
  205.  
  206.  
  207.    diskEvt     The Standard File Package takes care of all disk-inserted
  208.                events, so applications using this package can ignore
  209.                diskEvt events.  If your application is unusual and it
  210.                circumvents the Standard File package, your application
  211.                will have to handle disk-inserted events itself.
  212.  
  213.    networkEvt  Your application needs to respond to network events only
  214.                if it is going to be communicating with the AppleTalk
  215.                manager.  If it is, you should read the appropriate
  216.                documentation in chapter 10 Vol. 2 of Inside Macintosh
  217.                regarding networks.
  218.  
  219.    driverEvt   If your application does not intend to work with device
  220.                drivers, it can ignore these events.  Otherwise, you
  221.                should read the appropriate documentation in Inside
  222.                Macintosh regarding device drivers.
  223.  
  224.    app1Evt     Application-defined events 1 through 4.  These are events
  225.    app2Evt     whose meaning is defined by your application.  If your
  226.    app3Evt     application does not define custom events, it can ignore
  227.    app4Evt     these event codes.  Note that app4Evt (or osEvt) will
  228.    osEvt       only be reported if your application does not respond to
  229.                Suspend/Resume events.  See the SIZE resource for
  230.                details.  If your application does respond to Suspend/
  231.                Resume events, it will receive a doSuspend or doResume
  232.                Tools Plus event.
  233.  
  234.    kHighLevel- Your application needs to respond to these events only if
  235.      Evt       you have defined the SIZE resource to respond to high-
  236.                level events.  See the SIZE resource for details.
  237.  
  238.  
  239. Valid Polling Record Fields
  240. ``````````
  241. Poll.Event
  242.  
  243. ------------------------------------------------------------------------
  244.  
  245. doMoveWindow (event)
  246. ````````````````````
  247. Indicator that user moved a window.
  248.  
  249.   The doMoveWindow event reports that the user has repositioned a window by dragging it by its title bar.  Most applications will choose to ignore this event.
  250.  
  251. Programming Considerations
  252. ``````````````````````````
  253. • The dragged window might not be the active window.  The user can drag
  254.   an inactive window by holding down the Command key before beginning
  255.   the drag.
  256.  
  257. • If part or all of a window is exposed by the drag and needs to be
  258.   refreshed, a subsequent call to PollSystem will report a doRefresh
  259.   event for this window.
  260.  
  261. • Your application may call WindowStatus to obtain the window’s new
  262.   location in the screen’s global co-ordinates.
  263.  
  264. • This event will never occur when the watch cursor is displayed, since
  265.   the title bar cannot be clicked.
  266.  
  267. • A doMoveWindow event is not generated when the user drags a desk
  268.   accessory.  The process is handled automatically.
  269.  
  270. Valid Polling Record Fields
  271. ```````````````````````````
  272. Poll.Window
  273.  
  274. ------------------------------------------------------------------------
  275.  
  276. doGrowWindow (event)
  277. ````````````````````
  278. Indicator that user has changed a window’s size.
  279.  
  280.   The doGrowWindow event reports that the user has changed a window by dragging a window’s “size box.”  This will always occur on the active window.
  281.  
  282. Programming Considerations
  283. ``````````````````````````
  284. • Your application can call the WindowStatus procedure to obtain the
  285.   window’s new width and height in pixels.
  286.  
  287. • If the window is enlarged either vertically or horizontally, a
  288.   subsequent call to PollSystem will report a doRefresh event for this
  289.   window.
  290.  
  291. • This event will never occur when the watch cursor is displayed, since
  292.   the size box cannot be clicked.
  293.  
  294. • A doGrowWindow event is not generated when the user changes a desk
  295.   accessory’s size.  The process is handled automatically.
  296.  
  297. Valid Polling Record Fields
  298. ```````````````````````````
  299. Poll.Window
  300.  
  301. ------------------------------------------------------------------------
  302.  
  303. doClickDesk (event)
  304. ```````````````````
  305. Indicator that user clicked in the desk top.
  306.  
  307.   The doClickDesk event reports that the user has clicked in the desk top.  Most applications will choose to ignore this event, however, it can be used to deselect objects on the active window.
  308.  
  309. Programming Considerations
  310. ``````````````````````````
  311. • This event will never occur when a modal window is active, since
  312.   clicks cannot occur outside of the window.
  313.  
  314. • This event will never occur when the watch cursor is displayed, since
  315.   the desk top cannot be clicked.
  316.  
  317. Valid Polling Record Fields
  318. ```````````````````````````
  319. Poll.What
  320.  
  321. ------------------------------------------------------------------------
  322.  
  323. doZoomWindow (event)
  324. ````````````````````
  325. Indicator that user has changed a window’s size and/or location by zooming.
  326.  
  327.   The doZoomWindow event reports that the user has changed a window’s size and/or position by clicking the “zoom box.”  This will always occur on the active window.  Applications will typically ignore this event, or treat it similarly to the doGrowWindow event.
  328.  
  329. Programming Considerations
  330. ``````````````````````````
  331. • Your application can call the WindowStatus procedure to obtain the
  332.   window’s new width and height in pixels, as well as its new location
  333.   in the screen’s global co-ordinates.
  334.  
  335. • The window’s entire contents are erased during the zoom.  A subsequent
  336.   call to PollSystem will report a doRefresh event for this window.
  337.   Responding to the doRefresh event will regenerate the window’s
  338.   contents.
  339.  
  340. • This event will never occur when the watch cursor is displayed, since
  341.   the zoom box cannot be clicked.
  342.  
  343. • A doZoomWindow event is not generated when the user click’s a desk
  344.   accessory’s zoom box.  The process is handled automatically.
  345.  
  346. ------------------------------------------------------------------------
  347.  
  348. doSuspend (event)
  349. `````````````````
  350. Indicator that your application is about to be suspended.
  351.  
  352.   The doSuspend event reports that your application will be suspended (or become a “background” application) the next time you call PollSystem.  This occurs under MultiFinder or System 7 when a desk accessory or other application is launched, or when an inactive window belonging to a desk accessory or another application is activated.
  353.  
  354. Programming Considerations
  355. ``````````````````````````
  356. • If your application is cutting, copying or pasting specialized objects
  357.   (i.e. not text that is handled by editing fields), copy this material
  358.   from your local scrap to the clipboard.
  359.  
  360. ------------------------------------------------------------------------
  361.  
  362. doResume (event)
  363. ````````````````
  364. Indicator that your application has been resumed.
  365.  
  366.   The doResume event reports that your application has become the active application.  This occurs under MultiFinder or System 7 after your application has become suspended (see the doSuspend event).
  367.  
  368. Programming Considerations
  369. ``````````````````````````
  370. • If your application is cutting, copying or pasting specialized objects
  371.   (i.e. not text that is handled by text editing fields), you may want
  372.   to check the clipboard to see if it contains the specialized objects
  373.   that you can paste, then copy them to your local scrap.
  374.  
  375. ------------------------------------------------------------------------
  376.  
  377. SetNullTime
  378. ```````````
  379. Set the number of ticks (1/60 sec) your application can wait until it receives a doNothing event, and can perform one cycle of its background process.  These settings affect only doNothing events.
  380.  
  381.    pascal void SetNullTime (long ForegroundTime; long BackgroundTime);
  382.  
  383.    procedure SetNullTime (ForegroundTime, BackgroundTime: longint);
  384.  
  385.   ForegroundTime is the amount of time (in 1/60 second “ticks”) your application can wait between receiving doNothing events when the application is the active application.  You can specify a value from 0 (maximum background processing speed at the expense of other applications) to 15 (four cycles per second).
  386.  
  387.   BackgroundTime is the amount of time (in 1/60 second “ticks”) your application can wait between receiving doNothing events when the application is suspended (i.e. when another application is active under MultiFinder or System 7).
  388.  
  389.   By default, Tools Plus is initialized with ForegroundTime and BackgroundTime set to 0, meaning your application will have maximum performance at the expense of other applications and processes.  Normally, applications that do background processing will set ForegroundTime  to 1, and BackgroundTime  to a higher value, thus slowing down the background processing when your application is suspended.  If your application doesn’t do any background processing, use the maxNullTime constant to allow other applications and process the maximum utilization of the processor.
  390.  
  391.   Your application can change the values of ForegroundTime and BackgroundTime at any time.  The change will take effect the next time that PollSystem is called.
  392.  
  393. Also see:  WaitAvail.
  394.  
  395.   CONST                      {Background process scheduling          }
  396.     maxNullTime = $7FFFFFFF; {Infinite time between doNothing events }
  397.  
  398. ------------------------------------------------------------------------
  399.  
  400. WaitAvail
  401. `````````
  402. Determine if the Macintosh running your application supports scheduled processing.  This determines if SetNullTime’s settings will have any effect.
  403.  
  404.    pascal Boolean WaitAvail(void);
  405.  
  406.    function WaitAvail: BOOLEAN;
  407.  
  408.   This function returns a value of true if scheduled background processing is supported, or false if it is not.  If the Macintosh running your application doesn’t support scheduled background processing, then SetNullTime’s settings will have no effect, and your application will receive a doNothing event each time it calls PollSystem when there are no events available.  Internally, this routine reports if the WaitNextEvent trap is available to your application.
  409.  
  410. ------------------------------------------------------------------------
  411.  
  412. ResetMouseClicks
  413. ````````````````
  414. Discontinue a mouse’s “drag” or multiple clicks in progress.
  415.  
  416.    pascal void ResetMouseClicks(void);
  417.  
  418.  
  419.    procedure ResetMouseClicks;
  420.  
  421.   The PollSystem function is used to detect single-clicks, double-clicks, and triple-clicks, as well as dragging which occurs between a mouse-down and mouse-up event.  In some applications, it may suffice to know that the user pressed the mouse button with the cursor being within a specific region or cursor zone, without concern for the mouse button’s release.  Or an application may allow a single-click only, thereby disallowing double or triple clicks.
  422.  
  423.   In such cases, the ResetMouseClicks procedure can be used to tell Tools Plus that sufficient mouse information has been retrieved, and to reset the click and drag mechanism.  This reset will clear the current click or drag from PollSystem’s event queue.  The next time the mouse button in pressed down, it will be considered to be a first mouse-down of either a single-click, double-click, triple-click, or drag.
  424.  
  425. See PollSystem for details on how the system responds to mouse events.
  426.  
  427. ------------------------------------------------------------------------
  428.  
  429. ApplicationSuspended
  430. ````````````````````
  431. Determine if your application has been suspended (i.e. not the active application).
  432.  
  433.    pascal Boolean ApplicationSuspended(void);
  434.  
  435.    function ApplicationSuspended: BOOLEAN;
  436.  
  437.   This function returns a value of true if a desk accessory or another application is active under MultiFinder or System 7).  A value of false is returned if your application is active, even though your application may not have any windows open.
  438.  
  439.   When running under MultiFinder or System 7, your application needs to have a SIZE resource with the “AcceptSuspendEvents” bit set to “1.”  See the SIZE resource for details.
  440.  
  441. ------------------------------------------------------------------------
  442.  
  443. “Field To Event” Cross reference
  444. ````````````````````````````````
  445. The following table provides a quick cross reference between each field in the polling record, and which events make use of that field.
  446.  
  447. Poll.Button     doButton, doPictButton
  448.  
  449. Poll.Event      doClick, doClickControl, doManualEvent
  450.  
  451. Poll.Field      doClickField
  452.  
  453. Poll.Key…       doKeyDown, doAutoKey, doKeyUp
  454.  
  455. Poll.ListBox…   doListBox
  456.  
  457. Poll.Menu…      doMenu, doPopUpMenu
  458.  
  459. Poll.Modifiers  doGoAway, doButton, doMenu, doKeyDown, doAutoKey,
  460.                 doKeyUp, doClickControl, doPopUpMenu, doPictButton
  461.  
  462. Poll.Mouse…     doClick
  463.  
  464. Poll.ScrollBar… doScrollBar
  465.  
  466. Poll.What       doNothing, doChgWindow, doRefresh, doGoAway, doButton,
  467.                 doMenu, doKeyDown, doAutoKey, doKeyUp, doClickField,
  468.                 doScrollBar, doListBox, doClick, doPopUpMenu,
  469.                 doPictButton, doClickControl, doManualEvent,
  470.                 doMoveWindow, doGrowWindow, doClickDesk, doZoomWindow,
  471.                 doSuspend, doResume
  472.  
  473. Poll.Window     doChgWindow, doRefresh, doGoAway, doButton, doKeyDown,
  474.                 doAutoKey, doKeyUp, doClickField, doScrollBar,
  475.                 doListBox, doClick, doPopUpMenu, doPictButton,
  476.                 doClickControl, doMoveWindow, doGrowWindow, doZoomWindow
  477.